package com.atstudy.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @version v1.0
 * @description:
 * @author: admin
 * @date: 2023/1/10 16:09
 * @copyright: 博为峰
 */
public class DBUtils {
    private static final String MYSQL_URL = "jdbc:mysql://localhost:3306/29db";
    private static final String MYSQL_USER = "root";
    private static final String MYSQL_PASSWORD = "123456";
    private static Connection connection = null;

    //随类的加载而执行一次
    static {
        try {
            connection = DriverManager.getConnection(MYSQL_URL, MYSQL_USER, MYSQL_PASSWORD);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }

    public static Connection getConn() {
        return connection;
    }
}
